﻿using Styx.Common;
using Styx.CommonBot;
using Styx.TreeSharp;
using Styx.WoWInternals;
using Action = Styx.TreeSharp.Action;

namespace TuanHA_Combat_Routine
{
    public partial class Classname
    {
        #region BloodRotation

        //
        private static Composite BloodRotation()
        {
            return new PrioritySelector(
                AutoTarget(),
                new Action(delegate
                    {
                        //Hold dps on Dungeon or Raid in No Combat
                        if (TreeRoot.Current.Name != "DungeonBuddy" &&
                            (InDungeon ||
                             InRaid) &&
                            !Me.Combat &&
                            Me.CurrentTarget != null &&
                            IsEnemy(Me.CurrentTarget) &&
                            !Me.CurrentTarget.IsTargetingMyPartyMember &&
                            !Me.CurrentTarget.IsTargetingMyRaidMember &&
                            !Me.CurrentTarget.IsTargetingMeOrPet)
                        {
                            return RunStatus.Success;
                        }

                        if (THSettings.Instance.AutoAoE &&
                            THSettings.Instance.UnittoStartAoE > 0 &&
                            !InArena &&
                            !InBattleground &&
                            CountEnemyNear(Me, 10) >= THSettings.Instance.UnittoStartAoE)
                        {
                            _aoEModeOn = true;
                        }
                        else
                        {
                            _aoEModeOn = false;
                        }

                        return RunStatus.Failure;
                    }),
                //But first, facing target
                //FacingTarget(),
                //Starting the movement right here
                //MovementMoveBehind(ret => Me.CurrentTarget),
                //MovementMoveToLoS(ret => Me.CurrentTarget),
                MovementMoveStop(ret => Me.CurrentTarget, 3),
                MovementMoveToMelee(ret => Me.CurrentTarget),
                //DPS Rotation Here
                TargetMyPetTarget(),
                UseHealthstone(),
                UseBattleStandard(),
                //MindFreeze(),
                //DeathGripInterrupt(),
                EmpowerRuneWeapon(),
                BloodFury(),
                //PathofFrostJump(),
                BoneShield(),
                VampiricBlood(),
                IceboundFortitude(),
                IceboundFortitudeStun(),
                DesecratedGround(),
                //LichborneFear(),
                LichborneHeal(),
                AntiMagicShell(),
                AntiMagicShellLichborne(),
                AntiMagicShellEnemy(),
                AntiMagicShellDebuff(),
                AntiMagicShellCaster(),
                RuneTap(),
                DarkCommand(),
                DarkSimulacrum(),
                DarkSimulacrumUse(),
                DeathGripTaunt(),
                DeathGripFarUnit(),
                DeathGrip(),
                DeathGripAsphyxiateHelpFriend(),
                DeathGripRemorselessWinter(),
                BloodTap(),
                DeathsAdvance(),
                //Strangulate(),
                StrangulateLow(),
                //Asphyxiate(),
                DarkSimulacrumUse(),
                HornofWinterBuff(),
                RaiseAlly(),
                RaiseDead(),
                new Decorator(
                    ret => !_aoEModeOn,
                    new PrioritySelector(
                        AttackASAP(),
                        DarkSuccor(),
                        SoulReaper(),
                        GorefiendsGraspAoE(),
                        //GorefiendsGraspInterrupt(),
                        GorefiendsGraspAggro(),
                        GorefiendsGraspKiter(),
                        GorefiendsGraspMelee(),
                        RemorselessWinter(),
                        RemorselessWinterEnemyLowHP(),
                        RemorselessWinterEnemyNumber(),
                        RemorselessWinterBurst(),
                        DeathPact(),
                        DeathSiphon(),
                        Conversion(),
                        DeathCoilHeal(),
                        DancingRuneWeapon(),
                        DeathStrikeBloodShield(),
                        DeathStrikeBloodPvP(),
                        ChainsofIce(),
                        ChainsofIceMelee(),
                        DeathandDecaySnare(),
                        PlagueLeech(),
                        Outbreak(),
                        UnholyBlight(),
                        BloodBoilProc(),
                        RuneStrikeCap(),
                        IcyTouchDebuffBlood(),
                        BloodBoilRoilingBlood(),
                        Pestilence(),
                        PlagueStrikeDebuff(),
                        NecroticStrikeStack(),
                        //NecroticStrikeDebuff(),
                        DeathStrikeBlood(),
                        ControlUndead(),
                        ControlUndeadUpdate(),
                        HeartStrike(),
                        RuneStrike(),
                        BloodStrike(),
                        HornofWinter(),
                        Presence(),
                        DeathCoilBloodFrost(),
                        //DeathCoil(),
                        PathofFrost())),
                new Decorator(
                    ret => _aoEModeOn,
                    new PrioritySelector(
                        DarkSuccor(),
                        SoulReaper(),
                        DancingRuneWeapon(),
                        DeathStrikeBloodShield(),
                        DeathStrikeBloodPvP(),
                        ChainsofIce(),
                        DeathPact(),
                        DeathSiphon(),
                        Conversion(),
                        PlagueLeech(),
                        Outbreak(),
                        BloodBoilProc(),
                        RuneStrikeCap(),
                        UnholyBlight(),
                        BloodBoilRefreshDebuffAoE(),
                        DeathStrikeBlood(),
                        IcyTouchDebuffBloodAoE(),
                        PlagueStrikeBloodAoE(),
                        BloodBoilRoilingBlood(),
                        Pestilence(),
                        BloodBoil4Unit(),
                        DeathandDecay(),
                        HeartStrikeAoE(),
                        RuneStrike(),
                        HornofWinter(),
                        Presence(),
                        PathofFrost()
                        )
                    )
                //RestRotation()
                );
        }

        #endregion
    }
}